﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using VanTaiBLL;
using VanTaiProperty;
namespace VanTaiTMS.Page
{
    public partial class danh_muc_kho : System.Web.UI.Page
    {
        #region[Define]
        private DataTable dtItem;
        //private DataTable dtItemDetail;
        protected string StrAlert = "";
        private TMItem_BusinessLogic clsItem = new TMItem_BusinessLogic();
        #endregion

        #region[Controller]
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetItem();
            }
        }
        protected void cmdEdit_Click(object sender, EventArgs e)
        {
 
        }
        protected void cmdSerach_Click(object sender, EventArgs e)
        {
 
        }
        protected void cmdRefesh_Click(object sender, EventArgs e)
        {

        }
        //-------------list-view-----------------------
        protected void ListViewAll_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            //try
            //{
            //    lbThongBaoLoi.Text = "";
            //    txtMaNhomXe.Enabled = false;
            //    if (e.CommandName == "Accept")
            //    {
            //        string SenderId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;
            //        BindGridGroupVehicleDetail_Edit(int.Parse(SenderId));
            //        OpenDialog("#danhmucnhomxe");
            //        upNewUpdatePanel.Update();
            //        imgSave.ToolTip = "Cập nhật";
            //        flag = false;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    lbThongBaoLoi.Text = ex.ToString();
            //    OpenDialog("#thongbao");
            //    updatePanelThongBao.Update();
            //}
        }
        protected void ListViewAll_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                #region[Double_Click]
                LinkButton linkListName = (LinkButton)e.Item.FindControl("linkListName");
                LinkButton linkNote = (LinkButton)e.Item.FindControl("linkNote");
                string _jsDouble1 = ClientScript.GetPostBackClientHyperlink(linkListName, "");

                linkListName.Attributes["ondblclick"] = _jsDouble1;
                linkListName.Attributes["onclick"] = "return false;";
                #endregion

                #region[Char]
                if (linkListName.Text.Length > 12)
                {
                    linkListName.Text = linkListName.Text.Substring(0, 10).ToString() + "...";
                }
                if (linkListName.Text.Length == 12)
                {
                    linkListName.Text = linkListName.Text;
                }
                if (linkNote.Text.Length > 12)
                {
                    linkNote.Text = linkNote.Text.Substring(0, 10).ToString() + "...";
                }
                if (linkNote.Text.Length >= 12)
                {
                    linkNote.Text = linkNote.Text;
                }
                #endregion
            }
        }
        //-----------pagger-----------------------
        protected void DataPagerListAll_PreRender(object sender, EventArgs e)
        {
            GetItem();
        }
        #endregion

        #region[Function]
        protected void GetItem()
        {
            dtItem = clsItem.GetItem();
            if (dtItem != null && dtItem.Rows.Count > 0)
            {
                ListViewAll.DataSource = dtItem;
                ListViewAll.DataBind();
                ListViewAll.Visible = true;
                DataPagerListAll.Visible = true;
            }
            else
            {
                ListViewAll.Visible = false;
                DataPagerListAll.Visible = false;
            }
        }
        #endregion
    }
}